home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Interactive Web Graphics with Shout 3D
/
Interactive Web Graphics With Shout 3D.iso
/
pc
/
Code
/
Chapter Code.exe
/
Chapter09
/
StartStopPanel.java
< prev
next >
Wrap
Text File
|
2000-08-27
|
1KB
|
64 lines
package applets;
import shout3d.*;
import shout3d.core.*;
import shout3d.math.*;
public class StartStopPanel extends Shout3DPanel implements DeviceObserver {
TimeSensor timer;
boolean started = false;
public StartStopPanel (Shout3DApplet applet){
super(applet);
}
public void customInitialize() {
addDeviceObserver(this,"MouseInput", null);
timer =(TimeSensor) getNodeByName("world-TIMER");
}
protected void finalize() {
removeDeviceObserver(this,"MouseInput");
}
public boolean onDeviceInput(DeviceInput di, Object userData) {
MouseInput mi = (MouseInput) di;
switch (mi.which){
case MouseInput.DOWN:
//if animation is not started
if (!started) {
timer.start();
started = true;
return true;
}
//if already started
else {
timer.stop();
started = false;
return true;
}
}//end of switch
return false;
}
} //end of class